//app.js
var login = require('/utils/login.js')
App({
  onLaunch: function(e) {
    var that = this;
    let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
    console.log(extConfig)
    var storeId = extConfig.StoreId;
    that.globalData.storeId = storeId
    that.globalData.storeAppId = extConfig.StoreAppId;
    that.globalData.image300_300host = 'http://static.711688.net.cn/upload/store/' + storeId + '/product/show/thumb300_300/';
    that.globalData.image190_190host = 'http://static.711688.net.cn/upload/store/' + storeId + '/product/show/thumb190_190/';
    that.globalData.image800_800host = 'http://static.711688.net.cn/upload/store/' + storeId + '/product/show/thumb800_800/';
    that.globalData.image_logo_host = 'http://static.711688.net.cn/upload/store/' + storeId + '/classes/thumb70_70/';
    that.globalData.image_source = 'http://static.711688.net.cn/upload/store/' + storeId + '/product/show/source/';
    that.globalData.image_logo_banner = 'http://static.711688.net.cn/upload/store/' + storeId + '/widget/',
      that.globalData.image_logo_class = 'http://static.711688.net.cn/upload/store/' + storeId + '/classes/source/';
    if (extConfig.showAppoint) {
      that.showAppoint = extConfig.showAppoint;
    }
    if (extConfig.swiper_h) {
      that.swiper_h = extConfig.swiper_h;
    }
    wx.request({
      url: that.globalData.host + '/api/store/GetInfo',
      data: {
        id: that.globalData.storeId
      },
      success: function (res) {
        console.log(res)
        wx.setStorageSync('mallName', res.data.Data.Name);
      }
    })
  },
    onShow: function() {
        console.log('app onshow');
        login.login(this);
    },
    globalData: {
        //用户头像
        userInfo: null,
        //测试环境
        //host: 'http://localhost:8004',
        //正式环境注意地址中含有特定店铺ID，请更换
        storeId: 0,
        //小程序编号https://weapp.711688.net.cn
        storeAppId: 0,
        host: 'https://weapp.711688.net.cn',
        fenxiao_code: 'http://static.711688.net.cn/upload/user/',
        image300_300host: 'http://static.711688.net.cn/upload/store/0/product/show/thumb300_300/',
        image190_190host: 'http://static.711688.net.cn/upload/store/0/product/show/thumb190_190/',
        image800_800host: 'http://static.711688.net.cn/upload/store/0/product/show/thumb800_800/',
        image_logo_host: 'http://static.711688.net.cn/upload/store/0/classes/thumb70_70/',
        image_source: 'http://static.711688.net.cn/upload/store/0/product/show/source/',
        image_logo_banner: 'http://static.711688.net.cn/upload/store/0/widget/',
        image_logo_class: 'http://static.711688.net.cn/upload/store/0/classes/source/',
        //以下为不同模板设置参数
        showAppoint: true, //true为显示预约(如珠宝)false不显示（微街秀商城）
        swiper_h: 1 // 轮播模式1为小图、2为长图
    }
})